//随机BAN单位
//每个阵营随机ban 4个单位，ban的数量可修改

//下面这个变量count的数值决定了每个阵营ban多少个单位
//有概率重复，懒得去重了
let count = 4;
//下面是各个阵营的单位列表
let Soviet_unit = [
    //步兵
    "SovietScoutInfantry",
    "SovietAntiInfantryInfantry",
    "SovietAntiVehicleInfantry",
    "SovietEngineer",
    "SovietHeavyAntiVehicleInfantry",
    "SovietCommandoTech1",
    //载具
    "SovietSurveyor",
    "SovietScoutVehicle",
    "SovietAntiInfantryVehicle",
    "SovietAntiAirShip",
    "SovietHeavyAntiVehicleVehicleTech1",
    "SovietSledgeHammerSPG",
    "SovietAntiStructureVehicle",
    "SovietAntiVehicleVehicleTech3",
    "OverlordTank",
    "SovietMCV",
    //空中单位
    "SovietAntiGroundAircraft",
    "SovietFighterAircraft",
    "SovietInterceptorAircraft",
    "SovietAntiGroundAttacker",
    "SovietBomberAircraft",
    //水面单位
    "SovietAntiNavyShipTech1",
    "SovietAntiNavyShipTech2",
    "SovietAntiNavyShipTech3",
    "SovietAntiStructureShip",
];
let Allied_unit = [
    //步兵
    "AlliedScoutInfantry",
    "AlliedAntiInfantryInfantry",
    "AlliedAntiVehicleInfantry",
    "AlliedEngineer",
    "AlliedInfiltrationInfantry",
    "AlliedCommandoTech1",
    //载具
    "AlliedAntiInfantryVehicle",
    "AlliedAntiAirVehicleTech1",
    "AlliedAntiVehicleVehicleTech1",
    "PrismTank",
    "AlliedAntiStructureVehicle",
    "AlliedAntiVehicleVehicleTech3",
    "AlliedFutureTank",
    "AlliedMCV",
    //空中单位
    "AlliedAntiGroundAircraft",
    "AlliedFighterAircraft",
    "AlliedSupportAircraft",
    "AlliedInterceptorAircraft",
    "AlliedBomberAircraft",
    "AlliedGunshipAircraft",
    //水面单位
    "AlliedScoutInfantry",
    "AlliedAntiAirShip",
    "AlliedAntiNavyShipTech1",
    "AlliedAntiNavyShipTech3",
    "AlliedAntiStructureShip",
];
let Japan_unit = [
    //步兵
    "JapanScoutInfantry",
    "JapanAntiInfantryInfantry",
    "JapanAntiVehicleInfantry",
    "JapanEngineer",
    "JapanArcherInfantry",
    "JapanInfiltrationInfantry",
    "JapanAntiVehicleInfantryTech3",
    "JapanCommandoTech1",
    //载具
    "JapanInterceptorAircraft_Ground",
    "JapanLightTransportVehicle",
    "JapanAntiInfantryVehicle",
    "JapanAntiVehicleVehicleTech1",
    "JapanAntiAirVehicleTech1",
    "JapanSentinelVehicle",
    "JapanAntiStructureVehicle",
    "JapanAntiVehicleVehicleTech3",
    "JapanMCV",
    //水面单位
    "JapanInterceptorAircraft",
    "JapanNavyScoutShip",
    "JapanAntiAirShip",
    "JapanAntiVehicleShip",
    "JapanAntiNavalShipTech3",
    "JapanAntiStrucctureShip",
];
let Celestial_unit = [
    //步兵
    "CelestialScoutDrone",
    "CelestialAntiInfanryInfantry",
    "CelestialAntiVehicleInfantry",
    "CelestialEngineer",
    "CelestialAntiInfantryInfantryAdvanced",
    //载具
    "CelestialAntiInfantryVehicle",
    "CelestialAntiAirShip",
    "CelestialAntiVehicleVehicleTech1",
    "CelestialAntiStructureVehicle",
    "CelestialAntiVehicleVehicleTech3",
    "CelestialAntiVehicleVehicleTech4",
    //空中单位
    "CelestialAttackerAircraft",
    "CelestialFighterAircraft",
    "CelestialSupportAircraft",
    "CelestialInterceptorAircraft",
    "CelestialBomberAircraft",
    //水面单位
    "CelestialAntiInfantryVehicle_Water",
    "CelestialAntiAirShip_Water",
    "CelestialAlmightlyShip",
    "CelestialAntiNavyShipTech3",
    "CelestialAntiStructureShip",
];
let unit_id = [Soviet_unit, Allied_unit, Japan_unit, Celestial_unit];
let all_faction = ["Soviet", "Allied", "Japan", "Celestial"];
let unit_len = [
    Soviet_unit.length,
    Allied_unit.length,
    Japan_unit.length,
    Celestial_unit.length,
];
let All_Player = "<All Players>";

//生成随机数
let index = 0;
all_faction.forEach((faction) => {
    for (var i = 1; i <= count; i++) {
        let spt = script
            .begin()
            .setName(faction + "CreateRandomVar" + i)
            .condition("CONDITION_TRUE")
            .onTrue(
                "SET_RANDOM_COUNTER",
                faction + "RandomVar" + i,
                1,
                unit_len[index]
            );
        for (var j = 1; j <= unit_len[index]; j++) {
            spt = spt.onTrue(
                "ENABLE_SCRIPT",
                faction + "CheckRandomVar" + i + " " + j
            );
        }
        spt.ed("/" + faction);
    }
    index++;
});

//检查随机数
index = 0;
all_faction.forEach((faction) => {
    for (var i = 1; i <= count; i++) {
        for (var j = 1; j <= unit_len[index]; j++) {
            script
                .begin()
                .condition("COUNTER", faction + "RandomVar" + i, 2, j)
                .setName(faction + "CheckRandomVar" + i + " " + j)
                .setActive(false)
                .onTrue(
                    "ALLOW_DISALLOW_ONE_BUILDING",
                    All_Player,
                    unit_id[index][j - 1],
                    false
                )
                .ed("/" + faction + "/CheckRandom" + i);
        }
    }
    index++;
});
